/*单位后台*/
'use strict';
const unitAddAction = require('../actions/unit/unitAddAction');
const unitDelAction = require('../actions/unit/unitDelAction');
const unitUpdateAction = require('../actions/unit/unitUpdateAction');
const unitQueryAction = require('../actions/unit/unitQueryAction');

module.exports = async function (ctx) {
    let param = ctx.method === 'GET' ? ctx.query : ctx.request.fields;
    let action_type = param.action_type;
    try {
        switch (action_type) {
            case 'unitAdd': //单位添加
                ctx.body = await unitAddAction(param);
                break;
            case 'unitDel': //单位删除
                ctx.body = await unitDelAction(param);
                break;
            case 'unitUpdate': //单位修改
                ctx.body = await unitUpdateAction(param);
                break;
            case 'unitQuery': //单位查询
                ctx.body = await unitQueryAction(param);
                break;

        }
    } catch (e) {
        ctx.body = {success: false, message: e.message};
    }

};